package com.learning.daoImpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;

import com.learning.abstractdao.impl.LoginAbstractDaoImpl;
import com.learning.dao.LoginDao;
import com.learning.model.Users;

public class LoginDaoImpl extends LoginAbstractDaoImpl implements LoginDao {
	
	private static final Logger log = LoggerFactory.getLogger(LoginDaoImpl.class);

	public boolean checkLogin(Users user) {
		// TODO Auto-generated method stub
		StringBuilder sql = new StringBuilder();
		sql.append("Select * From Where username='");
		sql.append(user.getUsername()+"'");
		sql.append(" and ");
		sql.append("password='");
		sql.append(user.getPassword()+"'");
		log.debug("sql querry: ", sql.toString());
		List<Users> listUser = getJdbcTemplate().query(sql.toString(), mapper());
		if (listUser != null && listUser.size() > 0)
			return true;
		return false;
	}


}
